# -*- encoding: utf-8 -*-
"""
@author: CarpeDiem
@data: 22/9/22
@version: 0.1
@description: 整数转换为罗马数
@method:
"""
def intToRoman(num):
    thousands = ["", "M", "MM", "MMM"]
    hundreds = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"]
    tens = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"]
    ones = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]
    return thousands[num//1000] + hundreds[num%1000//100] + tens[num%100//10] + ones[num%10]

def main():
    print(intToRoman(4))
    print(intToRoman(9))
    print(intToRoman(58))
    print(intToRoman(1994))

main()
'''
    number_convert = {
            1: 'I',
            4: 'IV',
            5: 'V',
            9: 'IX',
            10: 'X',
            40: 'XL',
            50: 'L',
            90: 'XC',
            100: 'C',
            400: 'CD',
            500: 'D',
            900: 'CM',
            1000: 'M'
    }
    result = ""
    while num:
        if num >= 1000:
            temp = num // 1000
            result += number_convert[1000] * temp
            num = num % 1000
        elif num >= 900:
            temp = num // 900
            result += number_convert[900] * temp
            num = num % 900
        elif num >= 500:
            temp = num // 500
            result += number_convert[500] * temp
            num = num % 500
        elif num >= 400:
            temp = num // 400
            result += number_convert[400] * temp
            num = num % 400
        elif num >= 100:
            temp = num // 100
            result += number_convert[100] * temp
            num = num % 100
        elif num >= 90:
            temp = num // 90
            result += number_convert[90] * temp
            num = num % 90
        elif num >= 50:
            temp = num // 50
            result += number_convert[50] * temp
            num = num % 50
        elif num >= 40:
            temp = num // 40
            result += number_convert[40] * temp
            num = num % 40
        elif num >= 10:
            temp = num // 10
            result += number_convert[10] * temp
            num = num % 10
        elif num >= 9:
            temp = num // 9
            result += number_convert[9] * temp
            num = num % 9
        elif num >= 5:
            temp = num // 5
            result += number_convert[5] * temp
            num = num % 5
        elif num >= 4:
            temp = num // 4
            result += number_convert[4] * temp
            num = num % 4
        else:
            temp = num // 1
            result += number_convert[1] * temp
            num = num % 1
    return result
'''